import {Scanner} from "./scanner"
import {Parser} from "./parser"
import {genRender} from "./codegen"
export function baseCompile(template){
    // 将template转为tokens(即一个不可再分的部分, 如@click啥的)
    const tokens =  new Scanner(template).scan();
    // 生成ast树
    const ast = new Parser(tokens).parse();
    // 通过ast生成最终的render函数
    const render = genRender(ast);
    const code = `with(this){return ${render}}`;
    // console.log(code);
    return new Function(code);
 }
